package com.yunsom.testdemo.design.singleton;

/**
 * @author Xbao
 * @version 1.0
 * @description
 * @date 2021/3/9 18:29
 */
public class SingleObject {

  //让构造函数私有化，保证不会被实例化
  private SingleObject(){}

  //创建该类下的一个对象
  private static SingleObject instance = new SingleObject();

  //获取唯一可用的对象
  public static SingleObject getInstance(){
   return instance;
  }

  //编写一个方法用于确认对象实例获取成功
  public void showMessage(){
    System.out.println("hello");
  }

}
